package com.wisdom.benefit.jufa.product;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wisdom.benefit.jufa.R;

import java.util.ArrayList;

public class ChooseCityAdapter extends BaseAdapter {
    private ArrayList<String> datas;
    private Context context;

    public ChooseCityAdapter(ArrayList<String> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ChooseCityAdapter.ViewHolder holder = null;
        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.choose_city_item,parent,false);
            holder = new ChooseCityAdapter.ViewHolder();
            holder.nameTv = (TextView) convertView.findViewById(R.id.choose_item_tv);
            convertView.setTag(holder);
        }else {
            holder = (ChooseCityAdapter.ViewHolder)convertView.getTag();
        }
        holder.nameTv.setText(datas.get(position));

        return convertView;
    }

    static class ViewHolder{

        TextView nameTv;
    }
}
